#include <iostream>
using namespace std;

class Array2D{
	int rows;
	double ** data;
	
public:
	Array2D(int r) : rows(r){
		data = new double*[rows];
		for(int i=0;i<rows;i++){
			data [i] = new double[8];
		}
	}
	
	~Array2D() {
		for (int i = 0; i < rows; ++i) {
			delete[] data[i];
		}
		delete[] data;
		cout <<"释放了一个"<< rows <<"行8列的数组" ;
	}
	
	void setElem(int i,int j,double n){
		data[i][j] = n;
	}
	
	double getRows() const{
		return rows;
	}
	
	double getColumns(){
		return 8;
	}
	
	double getMaxOfRow(int n){
		double max = data[0][0];
		for(int i = n, j = 0; j < 8; j++){
			if(data[i][j]>max){
				max = data [i][j];
			}
		}
		return max;
	}
	
	double getMinOfRow(int n){
		double min = data[n][0];
		for(int i = n, j = 0; j < 8; j++){
			if(data[i][j] < min){
				min = data [i][j];
			}
		}
		return min;
	}
	
	
	double getAvgOfRow(int n){
		double sum = 0;
		for(int i= n,j = 0; j < 8; j++){
			sum += data[i][j];
		}
		return sum/8;
	}
	
	double getMaxOfArray(){
		double max = data[0][0];
		for(int  j = 0; j < 8;j++){
			for(int i = 0;i < rows;i++){
				if(data[i][j] > max){
					max = data [i][j];
				}
			}
		}
		return max;
	}
	
	double getMinOfArray(){
		double min = data[0][0];
		for(int  j = 0; j < 8;j++){
			for(int i = 0;i < rows;i++){
				if(data[i][j] < min){
					min = data [i][j];
				}
			}
		}
		return min;
	}
	
	double getAvgOfArray(){
		double sum = 0;
		for(int  j = 0; j < 8;j++){
			for(int i = 0;i < rows;i++){
				sum+=data[i][j];
			}
		}
		return sum/(rows*8);
	}
	
};


